libxl: fix guest networking on NetBSD
authorChristoph Egger <Christoph.Egger@amd.com>
Mon, 17 Jan 2011 17:18:38 +0000 (17:18 +0000)
committerChristoph Egger <Christoph.Egger@amd.com>
Mon, 17 Jan 2011 17:18:38 +0000 (17:18 +0000)
As previously reported when I start guests with xl then the
guest network does not work because the qemu-ifup script
no longer runs.

NetBSD doesn't have something like udev. Changing xm/xend,
libxl and xenbackendd to make everything behave the same way
is a lot more intrusive than enabling it for NetBSD again.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl_dm.c

index 6a34dcd4f159d2616e0dfb4a10ed22a3a27dafa5..878625253fcb1d1067e84bcfd9b996765835a10f 100644 (file)
 #include "libxl.h"
 #include "flexarray.h"
 
+static const char *libxl_tapif_script(libxl__gc *gc)
+{
+#ifdef __linux__
+    return libxl__strdup(gc, "no");
+#else
+    return libxl__sprintf(gc, "%s/qemu-ifup", libxl_xen_script_dir_path());
+#endif
+}
+
 static char ** libxl_build_device_model_args_old(libxl__gc *gc,
                                              libxl_device_model_info *info,
                                              libxl_device_nic *vifs,
@@ -129,8 +138,9 @@ static char ** libxl_build_device_model_args_old(libxl__gc *gc,
                 flexarray_vappend(dm_args,
                                 "-net", libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
                                                        vifs[i].devid, smac, vifs[i].model),
-                                "-net", libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,bridge=%s,script=no",
-                                                       vifs[i].devid, ifname, vifs[i].bridge), NULL);
+                                "-net", libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,bridge=%s,script=%s",
+                                                       vifs[i].devid, ifname, vifs[i].bridge, libxl_tapif_script(gc)),
+                                NULL);
                 ioemu_vifs++;
             }
         }
@@ -261,8 +271,8 @@ static char ** libxl_build_device_model_args_new(libxl__gc *gc,
                 flexarray_append(dm_args, libxl__sprintf(gc, "nic,vlan=%d,macaddr=%s,model=%s",
                             vifs[i].devid, smac, vifs[i].model));
                 flexarray_append(dm_args, "-net");
-                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=no",
-                            vifs[i].devid, ifname));
+                flexarray_append(dm_args, libxl__sprintf(gc, "tap,vlan=%d,ifname=%s,script=%s",
+                            vifs[i].devid, ifname, libxl_tapif_script(gc)));
                 ioemu_vifs++;
             }
         }